import request from '@/utils/request'

// 查询流程定义列表
export function listDefinition(query) {
  return request({
    url: '/flowable/definition/list',
    method: 'get',
    params: query
  })
}

// 查询流程定义列表
export function myListDefinition(query) {
  return request({
    url: '/flowable/definition/myList',
    method: 'get',
    params: query
  })
}

// 部署流程实例
export function definitionStart(deployId, data) {
  return request({
    url: '/flowable/definition/start/' + deployId,
    method: 'post',
    data: data
  })
}

export function definitionStartByCategory(category, data) {
  return request({
    url: '/flowable/definition/startByCategory/' + category,
    method: 'post',
    data: data
  })
}

// 获取流程变量
export function getProcessVariables(taskId) {
  return request({
    url: '/flowable/task/processVariables/' + taskId,
    method: 'get'
  })
}

// 获取流程表单数据
export function getProcessFormData(params) {
  return request({
    url: '/flowable/task/processFormData',
    method: 'get',
    params: params
  })
}

// 激活/挂起流程
export function updateState(params) {
  return request({
    url: '/flowable/definition/updateState',
    method: 'put',
    params: params
  })
}

// 指定流程办理人员列表
export function userList(query) {
  return request({
    url: '/flowable/definition/userList',
    method: 'get',
    params: query
  })
}

// 指定流程办理组列表
export function roleList(query) {
  return request({
    url: '/flowable/definition/roleList',
    method: 'get',
    params: query
  })
}

// 读取xml文件
export function readXml(deployId) {
  return request({
    url: '/flowable/definition/readXml/' + deployId,
    method: 'get'
  })
}

// 读取image文件
export function readImage(deployId) {
  return request({
    url: '/flowable/definition/readImage/' + deployId,
    method: 'get'
  })
}

// 读取image文件
export function getFlowViewer(procInsId, executionId) {
  return request({
    url: '/flowable/task/flowViewer/' + procInsId + '/' + executionId,
    method: 'get'
  })
}

// 读取xml文件
export function saveXml(data) {
  return request({
    url: '/flowable/definition/save',
    method: 'post',
    data: data
  })
}

// 新增流程定义
export function addDeployment(data) {
  return request({
    url: '/system/deployment',
    method: 'post',
    data: data
  })
}

// 修改流程定义
export function updateDeployment(data) {
  return request({
    url: '/system/deployment',
    method: 'put',
    data: data
  })
}

// 删除流程定义
export function delDeployment(deployId) {
  return request({
    url: '/flowable/definition/delete/' + deployId,
    method: 'delete',
  })
}

// 导出流程定义
export function exportDeployment(query) {
  return request({
    url: '/system/deployment/export',
    method: 'get',
    params: query
  })
}

// 配置表单查询接口
// 左侧未选
export function getConfigList(query) {
  return request({
    url: '/flowable/form/list',
    method: 'get',
    params: query
  })
}

// 右侧已选
export function getSelectionConfigList(id) {
  return request({
    url: '/flowable/form/deployFormList/' + id,
    method: 'get',
  })
}

// 保存已选
export function addDeployForm(data) {
  return request({
    url: '/flowable/form/addDeployForm',
    method: 'post',
    data: data
  })
}

// getAuthorityForm
export function getAuthorityForm(id, deployId) {
  return request({
    url: '/flowable/form/buildFormAuthList/' + id +'/' + deployId,
    method: 'get',
  })
}

// getAuthorityForm
export function postAuthorityForm(data) {
  return request({
    url: '/flowable/form/buildFormAuth',
    method: 'post',
    data: data
  })
}

// 获取用户列表
export function getUserList(query) {
  return request({
    url: '/flowable/userGroup/user/list',
    method: 'get',
    params: query
  })
}

// 获取组列表
export function getGroupList(query) {
  return request({
    url: '/flowable/userGroup/group/list',
    method: 'get',
    params: query
  })
}

// 保存新增编辑按钮form
export function btnFormSave(data) {
  return request({
    url: '/flowable/deployBtn',
    method: 'post',
    data: data
  })
}

// 回显指定的按钮详情
export function getbtnView(id) {
  return request({
    url: '/flowable/deployBtn/' + id,
    method: 'get',
  })
}

// 删除按钮列表
export function delBtnRow(btnId) {
  return request({
    url: '/flowable/deployBtn/delete/' + btnId,
    method: 'delete',
  })
}

// 获取配置表单任务标题的按钮
export function getComList(id) {
  return request({
    url: '/flowable/form/mainComponentList/' + id,
    method: 'get',
  })
}

// 任务标题保存
export function titleConfigSave(data) {
  return request({
    url: '/flowable/form',
    method: 'post',
    data: data
  })
}

// 任务标题保存
export function getTitleForm(tableId, deployId) {
  return request({
    url: '/flowable/form/' + tableId + '/' + deployId,
    method: 'get',
  })
}

// 获取节点列表
export function getNodeList(procDefId) {
  return request({
    url: '/flowable/form/nodeList/' + procDefId,
    method: 'get',
  })
}
